
import React from 'react';
import { Form, Button, Collapse } from 'antd';
import FormBuilder from 'antd-form-builder';
import { SearchOutlined } from '@ant-design/icons';


const { Panel } = Collapse;

export default (props) => {

  const handleFinish = values => {
    props.onSearch && props.onSearch({
      ...values,
      pageNum: 1
    });
  }

  return (
    <Collapse defaultActiveKey={["1"]}>
      <Panel header="筛选" key="1">
        <Form layout="inline" onFinish={handleFinish}>
          <FormBuilder meta={props.meta} />
          <Form.Item >
            <Button type="primary" icon={<SearchOutlined />} htmlType="submit">搜索</Button>
          </Form.Item>
          <Form.Item >
            {props.children}
          </Form.Item>
        </Form>
      </Panel>
    </Collapse>
  )
}